<?php
$selected = (isset($orderid)&&!empty($orderid));
if($selected)
{
	$selButCap = "Змінити";
	if(!isset($ordername)||strlen(trim($ordername))==0) $ordername = "Немає назви";
}
else
{
	$selButCap = "Вибрати";
	$ordername = "Не вибрано";
}
echo CHtml::tag('span',array("id"=>"ordernameElement"),$ordername);
echo "<br/>";
// the link that may open the dialog
echo CHtml::button($selButCap, array('onclick'=>'$("#ordersdialog").dialog("open"); return false;'));
echo CHtml::ajaxButton('Віддати', Chtml::normalizeUrl(array("products/processorder","action"=>"form","id"=>$orderid)),array("update"=>"#currentorder"),array("id"=>"formorderbutton","name"=>"formorderbutton","disabled"=>!$selected));
echo CHtml::ajaxButton('Закрити', Chtml::normalizeUrl(array("products/processorder","action"=>"close","id"=>$orderid)),array("update"=>"#currentorder"),array("id"=>"closeorderbutton","name"=>"closeorderbutton","disabled"=>!$selected));

echo CHtml::hiddenField('orderid',$orderid,array("id"=>"orderidElement"));
echo "<br />";
echo Chtml::textField('orderpay',0,array('id'=>'orderpay',"disabled"=>!$selected));

if(!empty($errors) && is_array($errors)) 
{
	foreach($errors as $error)
	{
		echo CHtml::tag("p",array('class'=>'errormessage'),$error);
	}
}

?>